/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sun.distributor.dao;

import com.sun.distributor.exceptions.SystemException;
import com.sun.distributor.objects.Customer;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 *
 * @author Administrateur
 */
public class DAO_Customer extends Abstract_DAO{

    public Customer getCustomer(int id) throws SystemException {
        try {
            Connection c = getConnection();
            Statement stmt = c.createStatement();
            ResultSet rs = stmt.executeQuery("select * from soa_customer where idCustomer=" + id);
            Customer cust;

            if (rs.next()) {
                cust = new Customer(rs.getInt("idCustomer"), rs.getString("customerName"), rs.getString("customerAddress"));
            } else {
               cust = new Customer(1, "coucou", "tu veux...");
            }
            return cust;
        } catch (Exception ex) {
            throw new SystemException(ex);
        }

    }
}
